﻿import QtQuick 2.0
import MainWindow 1.0
import UpMainWindow 1.0
import QtQuick.Window 2.2

Item {
    id: rect
    anchors.fill: parent

    Rectangle{
        anchors.fill: parent
        color: Qt.rgba(0.5, 0.5,0.5, 0.0)
        border.color: "red"
        border.width: 1
    }

    //拖拽
    MouseArea{
        anchors.fill: parent
        property point clickPos: "0,0"
        onPressed: {
            clickPos = Qt.point(mouse.x, mouse.y)
        }
        onPositionChanged: {
            var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)
            view.setX(view.x + delta.x)
            view.setY(view.y + delta.y)
        }
    }

    //底层opengl
    MainWindow{
        id: mainWindow
        SequentialAnimation on frame {
            NumberAnimation{ to: 200; duration: 5000; easing.type: Easing.Linear }
            NumberAnimation{ to: 0; duration: 5000; easing.type: Easing.Linear }
            loops: Animation.Infinite
            running: true
        }
    }

    //顶层opengl
    UpMainWindow{
        id: upmainWindow
        SequentialAnimation on frame {
            NumberAnimation{ to: 200; duration: 5000; easing.type: Easing.Linear }
            NumberAnimation{ to: 0; duration: 5000; easing.type: Easing.Linear }
            loops: Animation.Infinite
            running: true
        }
    }

    //中间层qml
    Rectangle {
        z: 0
        color: Qt.rgba(0, 0, 0, 1.0)
        radius: 10
        border.width: 1
        border.color: "white"
        anchors.fill: label
        anchors.margins: -10
    }

    Text {
        z: 2
        id: label
        color: "white"
        wrapMode: Text.WordWrap
        text: "Opengl 和 Qml 混合编程"
        anchors.horizontalCenter: parent.horizontalCenter
        y: 20
    }
}
